package top.zuli.package02.homework06;

public class Demo2 {
    void print(double... a){
        double min;
        double max;
        double sum;
        double avg;
        if (a.length > 0){
            min = a[0];
            max = a[0];
            sum = 0;
            avg = 0;
            for (int i = 0; i < a.length; i++) {
                if (min > a[i]){
                    min = a[i];
                }
                if (max < a[i]){
                    max = a[i];
                }
                sum += a[i];
                avg = sum / a.length;
            }
            System.out.println("最小值是："+min);
            System.out.println("最大值是："+max);
            System.out.println("总和是："+sum);
            System.out.println("平均值是："+avg);
        }
    }

    public static void main(String[] args) {
        Demo2 demo = new Demo2();
        demo.print(1.2,2.1,1.1,2.2,3.5,0.9,1.8,4.3);
        demo.print();
    }
}
